package sf.view.fields;

import java.util.ArrayList;
import java.util.HashMap;

import sf.model.fields.BoolFieldModel;

import sf.jsonloader.JsonLoader;

public class BoolFieldFactory implements AbstractFieldFactory {
    @SuppressWarnings("unchecked")    
    public HashMap<String, AbstractField> getFields(String tableCode) {
	JsonLoader jloader = JsonLoader.getInstance();
	HashMap<String, AbstractField> fields = new HashMap<String, AbstractField>();
	ArrayList columns = (ArrayList) jloader.get(tableCode, "columns");
	for (Object c : columns) {
	    if (((HashMap) c).get("dataType").equals("bit")) {
		BoolFieldModel bfm = new BoolFieldModel();
		// kako da setujem labele?
		String labelText = (String) ((HashMap) c).get("name");
		BoolField bf = new BoolField();
		bf.setLabelText(labelText); // NOTE proveri da li si ovo uradio
		// i u ostalim poljima
		bf.setModel(bfm);

		fields.put((String) ((HashMap) c).get("code"), bf);
	    }
	}

	return fields;
    }
}
